package cz.muni.fi.pa165.sme.client.converters;

import cz.muni.fi.pa165.sme.client.fo.SportActivityFO;
import cz.muni.fi.pa165.sportmanager.sportactivityws.SportActivity;
import org.springframework.core.convert.converter.Converter;

/**
 * @author jirankova
 */
public class SportActivityFO2SportActivityConverter implements Converter<SportActivityFO, SportActivity> {
	@Override
	public SportActivity convert(final SportActivityFO source) {
		if (source == null) {
			return null;
		}

		final SportActivity target = new SportActivity();
		final Long sourceId = source.getId();
		final Float sourceSpeed = source.getSpeed();

		target.setId(sourceId == null ? null : sourceId.toString());
		target.setSpeed(sourceSpeed == null ? null : sourceSpeed.toString());
		target.setTitle(source.getTitle());

		return target;
	}
}
